<!-- html  4 
  -->

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>

        let nums = 3.1415926;

        console.log("nums.toFixed(2)" ,nums.toFixed(4));
        

        //定义对象
        let p = new Object()
        p.name = "张三";
        p.age = 18;
        p.sayHi = function(){
          console.log("this.name ",this.name);
        }

        p.sayHi();



        //使用方法构造对象 ,方法的参数可以有默认值
        function Person(name ,age=18){
          this.name = name
          this.age = age;

          this.sayHi= function(){
            console.log(" function Person this.name ",this.name);
            console.log(" function Person  this.age ",this.age);
          }
        }

        //使用方法创建对象 
        let p2 = new Person("李四",20)
        p2.sayHi()

        let p3 = new Person("王五",19)
        p3.sayHi()

        let p4 = new Person("赵六")
        p4.sayHi();


        //使用json定义对象 
        let user = {
           name:'jhand',
           age:18,
           introduce:function(){
              console.log(" {} introduce this.name ",this.name);
              console.log(" {} introduce   this.age ",this.age);
           }


        }
        user.introduce()









    </script>
</head>

<body>




</body>

</html>